#include "DockTitleBarWidget.h"
#include "ui_DockTitleBarWidget.h"

#include <QDockWidget>
#include <QToolButton>

DockTitleBarWidget::DockTitleBarWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::DockTitleBarWidget)
{
    ui->setupUi(this);
    setAttribute(Qt::WA_StyledBackground, true);
    if (parent && parent->inherits("QDockWidget")) {
               QDockWidget* dock = qobject_cast<QDockWidget*>(parent);
               // 找到原标题栏的按钮（不同Qt版本可能需要调整）
               QList<QToolButton*> buttons = dock->findChildren<QToolButton*>();
               for (QToolButton* btn : buttons) {
                   ui->horizontalLayout->addWidget(btn);
               }
           }
}

DockTitleBarWidget::~DockTitleBarWidget()
{
    delete ui;
}

void DockTitleBarWidget::setTitle(const QString titleText)
{
    ui->label_Title->setText(titleText);
}
